package com.ruoyi.xuexiao.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.ruoyi.xuexiao.domain.entity.KsJbxxhz;
import com.ruoyi.xuexiao.domain.entity.KsTc;
import com.ruoyi.xuexiao.domain.param.KsTcCountParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 矿山基本信息汇总表Mapper层
 *
 * @author 齐浩宽
 * @since 2024年5月23日22:19:21
 */
@Mapper
public interface KsJbxxhzMapper extends MPJBaseMapper<KsJbxxhz>
{
    /**
     * 根据筛选条件查询矿山基本信息
     * @param tenementType
     * @return
     * @author 齐浩宽
     */
    @Select("SELECT kj.id, kj.xkzh, kj.ksmc, kj.szxzq,kj.szxzqmc, kj.kz, kj.sczt,kj.yxqq,kj.yxqz,kj.kyqr,kj.kcfs,dk.kzmc\n" +
            "FROM ks_jbxxhz kj\n" +
            "LEFT JOIN zd_kz dk ON dk.kzdm = kj.kz\n" +
            "WHERE \n" +
            "kj.kqlx = #{tenementType} \n" +
            "AND \n" +
            "kj.ksfl = 5 \n" +
            "AND \n" +
            "kj.kz NOT IN ('97010','17050') \n" +
            "AND \n" +
            "kj.xkzh NOT IN (SELECT xkzh FROM ks_ssj_pcorbc)\n" +
            "GROUP BY \n" +
            "kj.id,dk.kzmc")
    List<KsJbxxhz> selectAboutMines(@Param("tenementType") Integer tenementType);

    /**
     * 查询挂载数量
     * @param xkzhList
     * @author 窦凯欣
     */
    @Select("<script>" +
            "SELECT xkzh, COUNT(*) as count FROM ks_tc " +
            "WHERE xkzh IN " +
            "<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach> " +
            "GROUP BY xkzh" +
            "</script>")
    List<KsTcCountParam> selectCountByXkzhBatch(@Param("list") List<String> xkzhList);
}
